cmake_minimum_required(VERSION 3.10)
project(StudentManager C)

# 支持C11标准
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

# 确保中文正常显示（Windows下）
if(WIN32)
    add_compile_options(-finput-charset=UTF-8)
    add_compile_options(-fexec-charset=GBK)
endif()

# 学生库（核心功能）
add_library(student_lib
    src/student.c
    src/student_manager.c
)

# 主程序
add_executable(student_main
    src/main.c
)
target_link_libraries(student_main student_lib)

# 测试程序
add_executable(student_test
    test/test_main.c
    test/test_student.c
    test/test_student_manager.c
)
target_link_libraries(student_test student_lib)
target_include_directories(student_test PRIVATE src)

# 启用测试
enable_testing()
add_test(NAME AllTests COMMAND student_test)

# 设置主程序输出目录
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# 设置测试输出目录（可选）
set_target_properties(student_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})